package com.my.okhttps.test.vo.shebao2;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang.StringUtils;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * 社会保障卡信息查询入参
 * https://blog.csdn.net/wohaqiyi/article/details/87382509
 * @author timo 2021/3/3
 */
//@XmlRootElement表示当前标签的名字com.ejlchina.okhttps.Config
//@XmlType表示当前对象里，含有的下级标签对应的对象的属性名。
//@XmlElement表示当前对象的属性，对应到xml里的标签名。
@XmlAccessorType(XmlAccessType.FIELD)
//@XmlType(propOrder={"aac002","aac003"})
@XmlRootElement(name="input")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class InputXml {
    /**就业外出务工地查询  身份证*/
    @XmlElement(name="yac002")
    private String workIdCard;
    /**惠民惠农一卡通支付明细  年份*/
    @XmlElement(name="year")
    private String year;

    /**姓名*/
    @XmlElement(name="aac003")
    private String userName;
    /**身份证*/
    @XmlElement(name="aac002")
    private String idCard;
    /**接口编号*/
    @XmlElement(name="jybh")
    private String jybh;
    /**WZ1000社保卡信息查询*/
    public InputXml(String idCard) {
        this.idCard = idCard;
        this.userName = "";
    }
    /**社会保障卡卡号*/
    @XmlElement(name="aaz500")
    private String cardNo;
    /**机构编码*/
    @XmlElement(name="akb020")
    private String orgNo;
    /**行政区划 发卡地*/
    @XmlElement(name="aab034")
    private String areaNo;
    /**领卡人*/
    @XmlElement(name="aae435")
    private String getCardUserName;
    /**激活时间*/
    @XmlElement(name="aae036")
    private String activateData;
    /**移动电话*/
    @XmlElement(name="aae005")
    private String mobilePhone;
    /**经办人*/
    @XmlElement(name="aae011")
    private String operator;
    /**随机数*/
    @XmlElement(name="wsjs")
    private String random;
    /**后8字节ATR*/
    @XmlElement(name="atr")
    private String atr;
    /**WZ7000社会保障卡激活*/
    public InputXml(String userName, String idCard, String cardNo, String orgNo, String areaNo, String getCardUserName, String activateData, String mobilePhone, String operator, String random, String atr) {
        this.userName = userName;
        this.idCard = idCard;
        this.cardNo = cardNo;
        this.orgNo = orgNo;
        this.areaNo = areaNo;
        this.getCardUserName = getCardUserName;
        this.activateData = activateData;
        this.mobilePhone = mobilePhone;
        this.operator = operator;
        this.random = random;
        this.atr = atr;
    }

    public InputXml(String idCard, String cardNo) {
        this.idCard = idCard;
        this.cardNo = cardNo;
        this.userName = "";
    }

    public void buildAct(InputXml inputXml){
        inputXml.setOrgNo(StringUtils.isNotBlank(inputXml.getOrgNo())?inputXml.getOrgNo():"");
        inputXml.setAreaNo(StringUtils.isNotBlank(inputXml.getOrgNo())?inputXml.getOrgNo():"510500");
        inputXml.setMobilePhone(StringUtils.isNotBlank(inputXml.getMobilePhone())?inputXml.getMobilePhone():"");

        inputXml.setGetCardUserName(inputXml.getUserName());

        inputXml.setActivateData(DateUtil.today());
        inputXml.setOperator(inputXml.getUserName());
        inputXml.setRandom(RandomUtil.randomNumbers(16));
        inputXml.setAtr("");
    }

    /**证件类型*/
    @XmlElement(name="aac058")
    private String certificateType;
    /**数据来源*/
    @XmlElement(name="yae735")
    private String source;
    /**业务类型*/
    @XmlElement(name="ywlx")
    private String serviceType;
    /**行政区划2*/
    @XmlElement(name="aab301")
    private String areaNo2;
    /**G400社保卡挂失、解挂、冻结*/
    public InputXml(String userName, String idCard, String operator, String certificateType, String source, String serviceType, String areaNo2) {
        this.userName = userName;
        this.idCard = idCard;
        this.operator = operator;
        this.certificateType = certificateType;
        this.source = source;
        this.serviceType = serviceType;
        this.areaNo2 = areaNo2;
    }
    public void buildOtherOperation(InputXml inputXml){
        inputXml.setCertificateType("01");
        inputXml.setSource(StringUtils.isNotBlank(inputXml.getAreaNo())?inputXml.getAreaNo():"510500");
        inputXml.setAreaNo2(StringUtils.isNotBlank(inputXml.getAreaNo())?inputXml.getAreaNo():"510500");
        inputXml.setAreaNo(StringUtils.isNotBlank(inputXml.getAreaNo())?inputXml.getAreaNo():"510500");
        inputXml.setOperator(inputXml.getUserName());
    }

    /**卡识别码*/
    @XmlElement(name="aaz501")
    private String cardIcNo;
    /**养老险种(1:转移 0：不转移)*/
    @XmlElement(name="xz_110")
    private String yanglao;
    /**失业险种(1:转移 0：不转移)*/
    @XmlElement(name="xz_210 ")
    private String shiye;
    /**医疗险种(1:转移 0：不转移)*/
    @XmlElement(name="xz_310")
    private String yiliao;
    /**工伤险种(1:转移 0：不转移)*/
    @XmlElement(name="xz_410")
    private String gongshang;
    /**生育险种(1:转移 0：不转移)*/
    @XmlElement(name="xz_510")
    private String shengyu;
    /**新参保地*/
    @XmlElement(name="xz_aab301")
    private String newAnsuredAddr;
    /**个人编号*/
    @XmlElement(name="aac001")
    private String gerenNo;
    /**ZY1000 社会保障卡参保关系转移*/
    public InputXml(String userName, String idCard,String cardNo, String operator, String cardIcNo, String yanglao, String shiye, String yiliao, String gongshang, String shengyu, String newAnsuredAddr, String gerenNo,String areaNo) {
        this.userName = userName;
        this.idCard = idCard;
        this.cardNo = cardNo;
        this.operator = operator;
        this.cardIcNo = cardIcNo;
        this.yanglao = yanglao;
        this.shiye = shiye;
        this.yiliao = yiliao;
        this.gongshang = gongshang;
        this.shengyu = shengyu;
        this.newAnsuredAddr = newAnsuredAddr;
        this.gerenNo = gerenNo;
        this.areaNo = areaNo;
    }

    public void buildRelationTransfer(InputXml inputXml) {
        inputXml.setCardIcNo("510500D156000005A39389569985716C");
        inputXml.setYanglao("0");
        inputXml.setYiliao("1");
        inputXml.setGongshang("0");
        inputXml.setShiye("0");
        inputXml.setShengyu("0");

        inputXml.setNewAnsuredAddr("510500");
        inputXml.setOperator(inputXml.getUserName());
        inputXml.setGerenNo("");
        inputXml.setAreaNo(StringUtils.isNotBlank(inputXml.getAreaNo())?inputXml.getAreaNo():"510500");
    }
}
